using System;
using System.Collections.Generic;
using System.Text;

namespace DDW
{
	public class TypeNode : PrimaryExpression, IType
	{
		public TypeNode()
		{
		}
		public TypeNode(IdentifierExpression identifier)
		{
			this.identifier = identifier;
		}

		private IdentifierExpression identifier;
		public IdentifierExpression Identifier
		{
			get { return identifier; }
			set { identifier = value; }
		}

		private List<int> rankSpecifiers = new List<int>();
		public List<int> RankSpecifiers
		{
			get { return rankSpecifiers; }
			set { rankSpecifiers = value; }
		}

		public override void ToSource(StringBuilder sb)
		{
			identifier.ToSource(sb);

			if (rankSpecifiers.Count > 0)
			{
				foreach (int val in rankSpecifiers)
				{
					sb.Append("[");
					for (int i = 0; i < val; i++)
					{
						sb.Append(",");
					}
					sb.Append("]");					
				}
			}
		}
	}
}
